package com.drinkian.business.record.controller;

import com.drinkian.business.record.service.IRecordService;
import com.drinkian.entity.RequestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("record")
public class RecordController {

    @Autowired
    private IRecordService iRecordService;

    /**
     * @param current
     * @param size
     * @param userType 1是卖家，2是买家
     * @param userId
     * @param itemType 1是商品，2是房屋
     * @return
     */
    @GetMapping("getRecord")
    public RequestResult getRecord(@RequestParam("current") Integer current, @RequestParam("size") Integer size,
                                   @RequestParam("userType") Integer userType, @RequestParam("userId") Long userId,
                                   @RequestParam("itemType") Integer itemType) {
        return iRecordService.getRecord(current, size, userType, userId, itemType);
    }

    /**
     * @param id
     * @param userType seller是1，buyer是2
     * @return
     */
    @GetMapping("deleteRecord")
    public RequestResult deleteRecord(@RequestParam("id") Long id, @RequestParam("userType") Integer userType) {
        return iRecordService.deleteRecord(id, userType);
    }

    @GetMapping("confirmReceipt")
    public RequestResult confirmReceipt(@RequestParam("id") Long id) {
        return iRecordService.confirmReceipt(id);
    }
}
